package com.zhixin.fans.ks.ui.order;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.zhixin.fans.ks.R;
import com.zhixin.fans.ks.ui.base.BaseNeedLoginActivity;

import org.eenie.common.views.QMUIWindowInsetLinearLayout;
import org.eenie.common.views.TopBarLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


public class OrderListActivity extends BaseNeedLoginActivity implements BaseQuickAdapter.OnItemClickListener {
    public static final String ROUTE_PATH = "/order/list";
    @BindView(R.id.top_bar)
    TopBarLayout mTopBar;
    @BindView(R.id.edit_search)
    EditText mEditSearch;
    @BindView(R.id.btn_search)
    ImageView mBtnSearch;
    @BindView(R.id.ra_waiting)
    RadioButton mRaWaiting;
    @BindView(R.id.ra_all)
    RadioButton mRaAll;
    @BindView(R.id.ra_complete)
    RadioButton mRaComplete;
    @BindView(R.id.ra_cancel)
    RadioButton mRaCancel;
    @BindView(R.id.rv_order_list)
    RecyclerView mRvOrderList;
    @BindView(R.id.fragment_container)
    QMUIWindowInsetLinearLayout mFragmentContainer;

    OrderListAdapter mOrderListAdapter;
    List<String> mOrders = new ArrayList<>();


    @Override
    public int initContentView() {
        return R.layout.activity_order_list;
    }

    @Override
    public void initInjector() {

        for (int i = 0; i < 50; i++) {
            mOrders.add("");
        }

    }

    @Override
    public void initUiAndListener() {
        ButterKnife.bind(this);
        mRvOrderList.setLayoutManager(new LinearLayoutManager(mContext));
        mRvOrderList.setAdapter(mOrderListAdapter = new OrderListAdapter(mOrders));

        mOrderListAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void doOnBackPressed() {
        new QMUIDialog.MessageDialogBuilder(mContext)
                .setMessage("确定退出应用")
                .setTitle("提示")
                .addAction("取消", new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                    }
                })
                .addAction("确定", new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                        finish();
                    }
                })
                .create()
                .show();
    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        startActivity(new Intent(mContext, OrderDetailActivity.class));
    }
}
